<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/api/inc.jsp"%>
<%
	String accesstoken = "";
	Cookie[] cookies = request.getCookies();
	if(cookies!=null){
		for(Cookie cookie:cookies){
			if("uop_open_accesstoken".equals(cookie.getName())){
				accesstoken = cookie.getValue();
				break;
			}
		}
	}
%>
<script type="text/javascript">
function sub(){
	if(!$('#orderForm').form('validate')){
		$('#content-result').html('');
		$('#content-now-result').html('');
		return false;
	};
	var accesstoken = $('#accesstoken').val();
	var json = formToJsonStr('orderForm');
	if(!accesstoken || !json){
		$('#content-result').html('');
		$('#content-now-result').html('');
		return false;
	}
	$('#content-result').html(writeJson(json));
	var param = {
		access_token: accesstoken,
		json: json
	};
	$.post('<c:url value="/open/order/cancelorder?r="/>'+Math.random(), param, function(data){
		if(!data || !data.success_response && !data.error_response){
			$('#content-result').html('');
			$('#content-now-result').html('');
			return;
		}
		$('#content-now-result').html(writeJson(JSON.stringify(data)));
	}, 'json');
}
</script>
<body>
<%@ include file="/api/header.jsp"%>
<div class="container grid-s165m0">
	<div class="col-main bg_line">
		<div class="main-wrap">
			<div class="api-detail-bd" id="bd">
				<div>
					<h2 class="head-title" id="result">
						<img src="<c:url value='/api/images/tri_down.png'/>" style="cursor: pointer; margin-right: 5px;" onclick="changeHide(this,'content-submit')">输入参数
					</h2>
					<form id="orderForm">
						<div id="content-submit">
							<table class="api-table" cellspacing="0">
								<thead>
									<tr>
										<th width="20%" class="left">参数名</th>
										<th width="15%" class="middle">类型</th>
										<th width="15%" class="middle">是否必填</th>
										<th width="20%" class="left">示例值</th>
										<th width="30%" class="left">说明</th>
									</tr>
								</thead>
								<tbody>
									<tr class="odd">
										<td class="left">access_token</td>
										<td class="middle">String</td>
										<td class="middle"><a style="color:red;">必填</a></td>
										<td class="middle"><input type="text" value="<%=accesstoken%>" style="width: 300px;" id="accesstoken" class="easyui-validatebox" data-options="required:true"/></td>
										<td class="left"></td>
									</tr>
									<tr class="even">
										<td class="left">ids</td>
										<td class="middle">String</td>
										<td class="middle"></td>
										<td class="middle"><input type="text" value="" style="width: 300px;" name="ids" id="array_ids"/></td>
										<td class="left">订单ID<br />多个ID用","隔开</td>
									</tr>
									<tr>
										<td class="middle" colspan="5"><input type="button" class="button" onclick="sub()" value="-提交-"  style="width: 100px;"/></td>
									</tr>
								</tbody>
							</table>
						</div>
					</form>
				</div>
			</div>
			<div>
				<h2 class="head-title" id="result">
					<img src="<c:url value='/api/images/tri_down.png' />" style="cursor: pointer; margin-right: 5px;" onclick="changeHide(this,'content-result')">
					提交的参数为：
				</h2>
				<div id="content-result"></div>
			</div>
			<div>
				<h2 class="head-title" id="now_result" >
					<img src="<c:url value='/api/images/tri_down.png' />" style="cursor: pointer; margin-right: 5px;" onclick="changeHide(this,'content-now-result')">
					当前返回结果为：
				</h2>
				<div id="content-now-result" style="font-weight: bold;color: red;"></div>
			</div>
			<div>
				<h2 class="head-title " id="example">
					<img src="<c:url value='/api/images/tri_down.png' />" style="cursor: pointer; margin-right: 5px;" onclick="changeHide(this,'content-example')">
					返回示例
				</h2>
				<div id="content-example">
					<script type="text/javascript">
						var success = '{"success_response": {"code": "isv.success","msg": "操作成功","result": []}}';
						var error = '{"error_response":{"code":"isv.error","msg":"操作失败"}}';
						document.write('<p class="data-format">成功示例:</p>');
						document.write(writeJson(success));
						document.write('<p class="data-format">失败示例:</p>');
						document.write(writeJson(error));
					</script>
				</div>
			</div>
		</div>
	</div>
	<%@ include file="/api/order/left.jsp"%>
</div>
</body>